package com.hisicom.scqxspxcjc.sceneCheck.report.service;

import cn.hutool.core.util.StrUtil;
import com.hisicom.scqxspxcjc.base.dao.BaseRepository;
import com.hisicom.scqxspxcjc.base.service.BaseService;
import com.hisicom.scqxspxcjc.sceneCheck.report.domain.ReportInsp;
import com.hisicom.scqxspxcjc.sceneCheck.report.repostion.ReportInspRepository;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhonggls
 * @date 2020/12/21 14:12
 * @Explain
 */
@Service
public class ReportInspService implements BaseService<ReportInsp, String> {
    @Autowired
    private ReportInspRepository reportInspRepository;

    @Override
    public BaseRepository<ReportInsp, String> getRepository() {
        return reportInspRepository;
    }

    @Override
    public List<ReportInsp> findAll() {
        return getRepository().findAll(Sort.by(Sort.Direction.fromString("asc"), "sort"));
    }

    public List<ReportInsp> findByZjzxhId(@NonNull String zjzxhId) {
        return reportInspRepository.findByZjzxhId(zjzxhId);
    }

    public void deleteByZjzxhId(String zjzxhId) {
        if (StrUtil.isNotBlank(zjzxhId)) {
            reportInspRepository.deleteByZjzxhId(zjzxhId);
        }
    }
}
